package com.zzyl.controller.customer;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.dto.ReservationDto;
import com.zzyl.service.customer.CustomerReservationService;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.PageVo;
import com.zzyl.vo.ReservationCountVo;
import com.zzyl.vo.ReservationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customer/reservation")
@Api(tags = "客户预约管理")
public class CustomerReservationController extends BaseController {

    @Autowired
    private CustomerReservationService customerReservationService;

    @GetMapping("/cancelled-count")
    @ApiOperation("查询取消预约数量")
    public ResponseResult getCancelledCount() {
        Integer count =  customerReservationService.getCancelledCount();
        return success(count);
    }

    @GetMapping("/countByTime")
    @ApiOperation("查询每个时间段剩余预约次数")
    public ResponseResult getCountByTime(@RequestParam Long time) {
        List<ReservationCountVo> collect = customerReservationService.getCountByTime(time);
        return success(collect);
    }

    @PostMapping
    @ApiOperation("新增预约")
    public ResponseResult addReservation(@RequestBody ReservationDto dto){
        customerReservationService.addReservation(dto);
        return success();
    }

    @GetMapping("page")
    @ApiOperation("分页查询预约")
    public ResponseResult<PageVo> getReservationPage(ReservationDto dto){
        PageResponse<ReservationVo> page = customerReservationService.getReservationPage(dto);
        return success(page);
    }

    @PutMapping("/{id}/cancel")
    @ApiOperation("取消预约")
    public ResponseResult cancelReservation(@PathVariable("id") Long id){
        customerReservationService.cancelReservation(id);
        return success();
    }

}
